﻿CREATE PROCEDURE [dbo].[usp_select_Reports_AlertSubscriptionsOverTime]
(
   @BeginDate			varchar(25)      = '2000/1/1'   
   ,@EndDate			varchar(25)      = '2010/12/31'   
   ,@Debug              bit              = 0
)
AS

SET NOCOUNT ON;

-- Bootstrap
DECLARE @DebugPrefix       varchar(10)
DECLARE @ErrorCode         int

SET @ErrorCode          = 0;
SET @DebugPrefix        = '>>> DEBUG: '


select 
	[Application], 
	[ServiceName],
	count([Application]) as FiredCount, 
	convert( varchar, alertsubscriptionhistory.[inserteddate], 101) as FiredDate
from alertsubscriptionhistory
inner join alerthistory on alertsubscriptionhistory.alerthistoryid=alerthistory.alerthistoryid
where alertsubscriptionhistory.[inserteddate] between @BeginDate and @EndDate

group by [application], [ServiceName], convert( varchar, alertsubscriptionhistory.[inserteddate], 101)


SET NOCOUNT OFF;
